# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRun do
  @moduledoc """
  A data sync run of DataConnector. After DataConnector is successfully initialized, data syncs are scheduled at DataConnector.refresh_interval. A ConnectorRun represents a data sync either in the past or onging that the moment. //

  ## Attributes

  *   `endTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time when the connector run ended.
  *   `entityRuns` (*type:* `list(GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRunEntityRun.t)`, *default:* `nil`) - Output only. The details of the entities synced at the ConnectorRun. Each ConnectorRun consists of syncing one or more entities.
  *   `errors` (*type:* `list(GoogleApi.DiscoveryEngine.V1beta.Model.GoogleRpcStatus.t)`, *default:* `nil`) - Contains info about errors incurred during the sync. Only exist if running into an error state. Contains error code and error message. Use with the `state` field.
  *   `latestPauseTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time when the connector run was most recently paused.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Output only. The full resource name of the Connector Run. Format: `projects/*/locations/*/collections/*/dataConnector/connectorRuns/*`. The `connector_run_id` is system-generated.
  *   `startTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The time when the connector run started.
  *   `state` (*type:* `String.t`, *default:* `nil`) - Output only. The state of the sync run.
  *   `stateUpdateTime` (*type:* `DateTime.t`, *default:* `nil`) - Timestamp at which the connector run sync state was last updated.
  *   `trigger` (*type:* `String.t`, *default:* `nil`) - Output only. The trigger for this ConnectorRun.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :endTime => DateTime.t() | nil,
          :entityRuns =>
            list(
              GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRunEntityRun.t()
            )
            | nil,
          :errors => list(GoogleApi.DiscoveryEngine.V1beta.Model.GoogleRpcStatus.t()) | nil,
          :latestPauseTime => DateTime.t() | nil,
          :name => String.t() | nil,
          :startTime => DateTime.t() | nil,
          :state => String.t() | nil,
          :stateUpdateTime => DateTime.t() | nil,
          :trigger => String.t() | nil
        }

  field(:endTime, as: DateTime)

  field(:entityRuns,
    as:
      GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRunEntityRun,
    type: :list
  )

  field(:errors, as: GoogleApi.DiscoveryEngine.V1beta.Model.GoogleRpcStatus, type: :list)
  field(:latestPauseTime, as: DateTime)
  field(:name)
  field(:startTime, as: DateTime)
  field(:state)
  field(:stateUpdateTime, as: DateTime)
  field(:trigger)
end

defimpl Poison.Decoder,
  for: GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRun do
  def decode(value, options) do
    GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRun.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.DiscoveryEngine.V1beta.Model.GoogleCloudDiscoveryengineV1alphaConnectorRun do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
